<?php

class Client extends BaseClient
{
	public function __toString()
	{
		return $this->getNume();
	}

	public function getAdrese($tip=null)
  {
    return AdresaPeer::getForClient($this->getId(), $tip);
  }
  
  public function getGMapCloudCentered()
  {
    $g = new GMap();
    if (!($adrese = $this->getAdrese())) return null;
    foreach ($adrese as $i=>$adresa)
    {
      $geocoded = $g->geocode($adresa->getGmap());
      //marker nou cu adresa
      $gMarker = new GMapMarker($geocoded->getLat(),$geocoded->getLng(), array('title'=>'"'.$adresa->getGmap().'"'));
      $gMarker->addEvent(new GMapEvent('click', "window.open('".sfContext::getInstance()->getController()->genUrl("adrese/edit?id=".$adresa->getId())."').blur();"));
//      $gMarker->addHtmlInfoWindow(new GMapInfoWindow("<b>Adresa:</b><br />{$adresa->getGmap()}"));
      $g->addMarker($gMarker);
    }
    $g->centerAndZoomOnMarkers(0.3);
    return $g;
    //TODO: pune harta in footer si la useri si la furnizori (structura sql e deja)
  }
}
sfPropelBehavior::add('Client', array('sfPropelActAsSignableBehavior' => array())); 
